<html lang="zh">
<head>
    <style>
        * {
            margin: 0;
            padding: 0;
            text-decoration: none;
            list-style-type: none;
        }

        .a{
            width: 200px;
            position: relative;
            background-color: red;
        }
        .b{
            position: absolute;
            height: 50px;
        }

    </style>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>YXB</title>
</head>
<body>
<h1>YXB</h1>
<h1>css position absolute 做为子元素无法撑起父元素??</h1>
<h2>这个真的无解~~~</h2>
<h3>只能通过JS来间接地实现</h3>


<div class="a">aaa
    <div class="b">bbb</div>
</div>







</body>

<script>

    var one = document.querySelector(".b").offsetHeight;
    document.querySelector(".a").style.height = one+'px';

</script>
</html>